extends "res://tscn/book/tab.gd"


# Declare member variables here. Examples:
# var a = 2
# var b = "text"


# Called when the node enters the scene tree for the first time.

func initOptBtns():
	opt1.setTagName('Mod')
	opt4.setTagName('类型')
	opt1.setItems(tag1List)
	opt4.setItems(tag2List)
	chaNum.hide()

func init():
	if isShow : 
		reInit()
		return
	box.set_columns(8)
	isShow = true
	for i in data.getList("k") :
		var item = data.newBase(i.id)
		if item.lock == -1 :continue
		var bt = preload("res://tscn/charaDlg/skill/skillBtn.tscn").instance()
		if item.tab != null and not tag2List.has(item.tab):
			tag2List.append(item.tab)
			
		addItem(item,bt)
		bt.initTip()

func reInit():
	var skillBtns = box.get_children()
	for btn in skillBtns:
		var canShow = true 
		if selectTag1 and selectTag1 != utils.getModNameFromData(btn.skill):
			canShow = false
			
		if selectTag2 and selectTag2 != btn.skill.tab:
			canShow = false 
			
		if findName != null and canShow:
			for text in findName.split(" "):
				if text and text.length() > 0 and text.find(" ") < 0:
					var regex = RegEx.new()
					regex.compile(".*" + text +".*")
					var result = regex.search(btn.skill.name)
					canShow = canShow and is_instance_valid(result)
			
		btn.set_visible(canShow)

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass
